package day6;

/**
 * @author oldliu
 * @since 1.0
 */
public class SecondMAx {
    public static void main(String[] args) {
        int[] a = {-1, -1, -22, -22, -22, -22, -22, -22, -22, -22, -22, -22};
        int max = a[0];
        int second = a[1];
        for (int i = 0; i < a.length; i++) {
            //a[i],max,second比较
            //如果max>=second>=a[i],不用改动
            if (a[i] > max) {
                second = max;
                max = a[i];
            } else if (a[i] < max && a[i] > second || max == second) {
                second = a[i];
            }
        }
        if (max == second) {
            System.out.println("大家都一样大，没有第二大的");
        } else {
            System.out.println("第二大的是" + second);
        }
    }
}
